//常用的高阶函数
//模拟 map / every / some 
//map 遍历数组元素并对其进行处理，返回处理结果
const map = (array, fn) => {
    let results = [];
    for(let value of array){
        results.push(fn(value));
    }
    return results;
} 

//every  遍历数组元素是否全部符合条件
const every = (array, fn) => {
    let result = true;
    for( let value of array){
        result = fn(value);
        if(!result){
            break;
        }
    }
    return result;
}

//some  遍历数组元素是否含有符合条件的元素
const some = (array,fn) => {
    let result = false;
    for(let value of array){
        result = fn(value);
        if(result){
            break;
        }
    }
    return result;
}
